package ModelLayer;
/**
 * This class is part of an address book system. It's an aggregation of class DVD, and contains
 * data for Copy objects contained within the DVD. 
 *
 * The purpose of this class is to supply information to the DVD and the ControlLayer. 
 * 
 * @author Anders A.P, Anna K., Danny M.P., Jakob K., Mie P.  
 * @version 1.0
 */
public class Copy
{
    private int     serialNr;
    private String  purchaseDate;
    private double  purchasePrice;

    /**
     * Constructs an instance of Copy, taking the following parameters:
     * 
     * @param   serialNr        Serial number of the copy (has to be a number bigger than 0).
     * @param   purchaseDate    Date of the purchase of the copy (has to by more than 1 character).
     * @param   purchasePrice   Purchase price of the copy (has to be an amount more than 0). 
     * @throw   Exception       If the parameters are blank.
     */
    public Copy(int serialNr, String purchaseDate, double purchasePrice)
    {
        if (!setSerialNr(serialNr)) {
            throw new IllegalArgumentException("invalid serial number");
        }
        if (!setPurchaseDate(purchaseDate)) {
            throw new IllegalArgumentException("invalid date");
        }
        if (!setPurchasePrice(purchasePrice)) {
            throw new IllegalArgumentException("invalid price");
        }
    }
    
    /**
     * Sets the serial number of the copy.
     * 
     * @param   serialNr    Serial number of the copy (has to be a number bigger than 0).
     * @return  false       If serial number is not bigger than 0.
     * @return  true        If serial number is bigger than 0.
     */
    public boolean setSerialNr(int serialNr)
    {
        if (serialNr > 0) {
            this.serialNr = serialNr;
            return true;
        }
        else {
            return false;
        }    
    }
    
    /**
     * Sets the purchase date of the copy .
     * 
     * @param   purchaseDate    The purchase date of the copy (has to by more than 1 character).
     * @return  false           If purchase date is not longer than 1 character.
     * @return  true            If purchase date is longer than 1 character.
     */
    public boolean setPurchaseDate(String purchaseDate)
    {
        if (purchaseDate.trim().length() > 0) {
            this.purchaseDate = purchaseDate;
            return true;
        }
        else {
            return false;
        }
    }
    
    /**
     * Sets the purchase price of the copy.
     * 
     * @param   purchasePrice   Purchase price of the copy (has to be an amount more than 0). 
     * @return  false           If the amount is not more than 0.
     * @return  true            If the amount is more than 0.
     */
    public boolean setPurchasePrice(double purchasePrice)
    {
        if (purchasePrice > 0) {
            this.purchasePrice = purchasePrice;
            return true;
        }
        else {
            return false;
        }
    } 

    /**
     * Returns the value of the field serialNr to the caller.
     *
     * @return  serialNr    Returns Copy purchaseDate.
     */   
    public int getSerialNr()
    {
        return this.serialNr;
    }

    /**
     * Returns the value of the field purchaseDate to the caller.
     *
     * @return  purchaseDate    Returns Copy purchaseDate.
     */      
    public String getPurchaseDate()
    {
        return this.purchaseDate;
    }

    /**
     * Returns the value of the field purchasePrice to the caller.
     *
     * @return  purchasePrice   Returns Copy purchasePrice.
     */      
    public double getPurchasePrice()
    {
        return this.purchasePrice;
    }

    
//     /**
//      * Returns the value of the field id to the caller.
//      *
//      * @return  id  Returns Copy id.
//      */    
//     public int getID()
//     {
//         return id;
//     }  

}
